package com.softroad.help.app.tools;

import java.text.SimpleDateFormat;
import java.util.Date;

import android.util.Log;

public class DateChannel {

	public static String channelYear(String content) {
		if (!StringTool.isNoBlankAndNoNull(content)) {
			return "";
		} else {
			return content.substring(0, 4).toString().trim();

		}
	}

	public static String channelMonth(String content) {
		if (!StringTool.isNoBlankAndNoNull(content)) {
			return "";
		} else { 
			return content.substring(5, 7).toString().trim();

		}
	}

	public static String channelDay(String content) {
		if (!StringTool.isNoBlankAndNoNull(content)) {
			return "";
		} else {
			return content.substring(8, 10).toString().trim();
		}
	}

	public static String channelStartTime(String content) {
		if (!StringTool.isNoBlankAndNoNull(content)) {
			return "";
		} else {
			return content.substring(11, 13).toString().trim();

		}
	}

	public static String channelEndTime(String content) {
		if (!StringTool.isNoBlankAndNoNull(content)) {
			return "";
		} else {
			return content.substring(31, 33).toString().trim();

		}
	}

	public static int channelTotal(String content) {
		return Integer.parseInt(channelEndTime(content))
				- Integer.parseInt(channelStartTime(content));

	}

	public static String dayFormate(String content) {
		return content.substring(0, 4).toString().trim() + "-"
				+ content.substring(5, 7).toString().trim() + "-"
				+ content.substring(8, 10).toString().trim();
	}

	public static String getWeekday(String date) {// 必须yyyy-MM-dd
		SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd");
		SimpleDateFormat sdw = new SimpleDateFormat("E");
		Log.e("data", date + "");
		Date d = null;
		try {
			d = sd.parse(date);
		} catch (java.text.ParseException e) {
			e.printStackTrace();
		}
		return sdw.format(d);
	}
}
